﻿using System;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using System.Xml.Serialization;
using Microsoft.Xna.Framework.Content;

namespace Gamev1
{
    #region XML Includes
    [XmlInclude(typeof(Character))]
    [XmlInclude(typeof(Platform))]
    [XmlInclude(typeof(Item))]
    [XmlInclude(typeof(Enemy))]
    [XmlInclude(typeof(Weapon))]
    [XmlInclude(typeof(Portal))]
    #endregion

    public abstract class Sprite
    {
        public enum Direction
        {
            Left = 0,
            Right = 1
        }

        #region Getters & setters
        [XmlIgnore]
        public Texture2D Texture { get; set; }
        [XmlIgnore]
        public bool canBeRemoved { get; set; }
        public String TexturePath { get; set; }
        public Vector2 Position { get; set; }
        public Color Color;
        public Rectangle Rectangle
        {
            get
            {
                return new Rectangle(
                   (int)Position.X,
                   (int)Position.Y,
                    //Texture.Width,
                    //Texture.Height);
                   100,
                   100);
            }
        }

        #endregion

        public Sprite()
        {
            canBeRemoved = false;
            Color = Color.White;
        }

        #region Methods
        public virtual void update(GameTime gameTime) { }
        public virtual void collisionWith(Sprite sprite) { }
        public virtual void draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Texture, Position, Color);
        }

        public bool isCollidingWith(Sprite otherSprite)
        {
            return this.Rectangle.Intersects(otherSprite.Rectangle);
        }

        public virtual void loadContent(ContentManager content)
        {
            Texture = content.Load<Texture2D>(TexturePath);
        }
        #endregion
    }
}
